package org.github.rayson517.easyplatform;

import org.github.rayson517.easyplatform.message.constant.SystemConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.Bean;

import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.annotation.SpringAnnotationScanner;

/**
 * 目前不需要链接数据库, 就需要将以下两个类给排除掉
 * DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class
 * @author rayson517
 *
 */
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class MessageApplication {
	
	private static final Logger log = LoggerFactory.getLogger(MessageApplication.class);
	
	public static void main(String[] args) {
		SpringApplication.run(MessageApplication.class, args);
	}
	
	@Bean
	public SocketIOServer socketIOServer(){
		Configuration config = new Configuration();
		config.setHostname(SystemConstant.SOCKETIO_HOST);
		config.setPort(SystemConstant.SOCKETIO_PORT);
		final SocketIOServer server = new SocketIOServer(config);
		return server;
	}
	
	@Bean
	public SpringAnnotationScanner springAnnotationScanner(SocketIOServer socketIOServer){
		return new SpringAnnotationScanner(socketIOServer);
	}
}
